package cxf.spring.demo.domain.message;

import cxf.spring.demo.adapter.DateAdapter;

import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.Date;
import java.util.List;
import java.util.ArrayList;

/**
 * Message bean
 *
 * User: Vlad Vinichenko (akerigan@gmail.com)
 * Date: 06.03.2009
 * Time: 20:22:30
 */
@XmlRootElement(name = "message")
@XmlAccessorType(XmlAccessType.FIELD)
public class Message {

    /**
     * Message id
     */
    @XmlElement(name = "id")
    int id;

    /**
     * Sender login
     */
    @XmlElement(name = "sender")
    String sender;

    /**
     * Recipients logins
     */
    @XmlElement(name = "recipient")
    List<String> recipients = new ArrayList<String>();

    /**
     * Message subject
     */
    @XmlElement(name = "subject")
    String subject;

    /**
     * Message text
     */
    @XmlElement(name = "text")
    String text;

    
    @XmlElement(name = "created")
    @XmlJavaTypeAdapter(DateAdapter.class)
    Date created;

    @XmlElement(name = "received")
    @XmlJavaTypeAdapter(DateAdapter.class)
    Date recieved;

    @XmlElement(name = "attachment")
    List<MessageAttachment> attachments = new ArrayList<MessageAttachment>();

    @XmlElement(name = "is-read")
    boolean messageRead;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getSender() {
        return sender;
    }

    public void setSender(String sender) {
        this.sender = sender;
    }

    public List<String> getRecipients() {
        return recipients;
    }

    public void setRecipients(List<String> recipients) {
        this.recipients = recipients;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public Date getRecieved() {
        return recieved;
    }

    public void setRecieved(Date recieved) {
        this.recieved = recieved;
    }

    public List<MessageAttachment> getAttachments() {
        return attachments;
    }

    public void setAttachments(List<MessageAttachment> attachments) {
        this.attachments = attachments;
    }

    public boolean isMessageRead() {
        return messageRead;
    }

    public void setMessageRead(boolean messageRead) {
        this.messageRead = messageRead;
    }
}
